package com.bitcat.wanandroidapp.demo

import android.os.Bundle
import android.widget.Button
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.bitcat.base.widget.dialog.LoadingDialog
import com.bitcat.wanandroidapp.R

class TestDialogActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_test_dialog)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        findViewById<Button>(R.id.button).setOnClickListener {
            //直接构造
            //LoadingDialog(this,"加载中").show()

            // 使用Builder建造者模式
            LoadingDialog.Builder(this)
                .setTitle("提示")
                .setCancelable(true)
                .setCancelOutside(true)
                .build()
                .show()
        }
    }
}